package com.blb.marry.config;

import com.blb.marry.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @author lvtian
 * @date 2023/1/11 10:09
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;

    //拦截器注册 记得提前注入或者@Bean方法
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //在拦截器注册中添加自定义拦截器
//        registry.addInterceptor(new HelloInterceptor())
                //配置拦截路径 /**代表所有路径
//                .addPathPatterns("/**")
                //排除路径
//                .excludePathPatterns("/**/world","/**/helloworld","/**/*.js","/**/*.css","/**/*.jpg");
//        registry.addInterceptor(loginInterceptor).addPathPatterns("/**")
//                .excludePathPatterns("/**/login.html","/**/login","/**/*.js","/**/*.css","/**/*.jpg","/**/*.PNG");
//        registry.addInterceptor(loginInterceptor)
//                .excludePathPatterns("/**");

    }

//    file:F://img/
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img/**").addResourceLocations("file:F://img/");
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");


    }

}

